package com.lantosec.hmrp.modules.report.controller;

import com.lantosec.hmrp.core.kit.PageVO;
import com.lantosec.hmrp.core.kit.Result;
import com.lantosec.hmrp.modules.report.service.IClinicalMedicationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


@Api(value = "临床用药控制器", tags = "临床用药控制器")
@RestController
@RequestMapping("/report/clinical/medication")
@Log4j2
public class ClinicalMedicationController {
    @Autowired
    private IClinicalMedicationService iClinicalMedicationService;

    @GetMapping("getAntimicrobialsInpatients")
    @ApiOperation(value = "住院患者抗菌药使用率监控(1)")
    public Result<PageVO<Map<String,Object>>> getAntimicrobialsInpatients(@ApiParam(value = "分页",required = true) PageVO<Map<String,Object>> page,
                                                                               @ApiParam(value = "开始时间") @RequestParam(name = "startTime",required = false) String startTime,
                                                                             @ApiParam(value = "结束时间") @RequestParam(name = "endTime",required = false) String endTime,
                                                                             @ApiParam(value = "科室名称") @RequestParam(name = "deptName",required = false) String deptName,
                                                                             @ApiParam(value = "账期状态", required = true) @RequestParam(name = "dateState") Integer dateState,
                                                                             @ApiParam(value = "科室名称状态", required = true) @RequestParam(name = "deptState") Integer deptState){
        PageVO<Map<String,Object>> reportInnerAntibacUseRateList = iClinicalMedicationService.getAntimicrobialsInpatientsList(page,startTime,endTime,deptName,dateState,deptState);
        return Result.ok(reportInnerAntibacUseRateList);
    }

    @GetMapping("getAntibioticsOutpatients")
    @ApiOperation(value = "门急诊患者抗菌药使用率监控(2)")
    public Result<PageVO<Map<String,Object>>> getAntibioticsOutpatients(@ApiParam(value = "分页",required = true) PageVO<Map<String,Object>> page,
                                                                              @ApiParam(value = "开始时间") @RequestParam(name = "startTime",required = false) String startTime,
                                                               @ApiParam(value = "结束时间") @RequestParam(name = "endTime",required = false) String endTime,
                                                               @ApiParam(value = "科室名称") @RequestParam(name = "deptName",required = false) String deptName,
                                                               @ApiParam(value = "诊疗类型") @RequestParam(name = "diagTreatType",required = false) String diagTreatType,
                                                               @ApiParam(value = "账期状态", required = true) @RequestParam(name = "dateState") Integer dateState,
                                                               @ApiParam(value = "科室名称状态", required = true) @RequestParam(name = "deptState") Integer deptState,
                                                               @ApiParam(value = "诊疗类型状态", required = true) @RequestParam(name = "diagTreatState") Integer diagTreatState){
        PageVO<Map<String,Object>> reportClinicAntibacUseRatesList = iClinicalMedicationService.getAntibioticsOutpatientsList(page,startTime,endTime,deptName,diagTreatType,dateState,deptState,diagTreatState);
        return Result.ok(reportClinicAntibacUseRatesList);
    }

    @GetMapping("getAntimicrobialUse")
    @ApiOperation(value = "抗菌药物使用情况监控(3)")
    public Result<PageVO<Map<String,Object>>> getAntimicrobialUse(@ApiParam(value = "分页",required = true) PageVO<Map<String,Object>> page,
                                                                  @ApiParam(value = "开始时间") @RequestParam(name = "startTime",required = false) String startTime,
                                                                  @ApiParam(value = "结束时间") @RequestParam(name = "endTime",required = false) String endTime,
                                                                  @ApiParam(value = "科室名称") @RequestParam(name = "deptName",required = false) String deptName,
                                                                  @ApiParam(value = "医生名称") @RequestParam(name = "docName",required = false) String docName,
                                                                  @ApiParam(value = "诊疗类型") @RequestParam(name = "diagTreatType",required = false) String diagTreatType,
                                                                  @ApiParam(value = "账期状态", required = true) @RequestParam(name = "dateState") Integer dateState,
                                                                  @ApiParam(value = "科室名称状态", required = true) @RequestParam(name = "deptState") Integer deptState,
                                                                  @ApiParam(value = "医生名称状态", required = true) @RequestParam(name = "docNameState") Integer docNameState){
        PageVO<Map<String,Object>> reportAntibacDrugUseList = iClinicalMedicationService.getAntimicrobialUseList(page,startTime,endTime,deptName,docName,diagTreatType,dateState,deptState,docNameState);
        return Result.ok(reportAntibacDrugUseList);
    }

    @GetMapping("getStrengthAntimicrobialUse")
    @ApiOperation(value = "抗菌药物使用强度监控(4)")
    public Result<PageVO<Map<String,Object>>> getStrengthAntimicrobialUse(@ApiParam(value = "分页",required = true) PageVO<Map<String,Object>> page,
                                                                      @ApiParam(value = "开始时间") @RequestParam(name = "startTime",required = false) String startTime,
                                                                      @ApiParam(value = "结束时间") @RequestParam(name = "endTime",required = false) String endTime,
                                                                      @ApiParam(value = "科室名称") @RequestParam(name = "deptName",required = false) String deptName,
                                                                      @ApiParam(value = "账期状态", required = true) @RequestParam(name = "dateState") Integer dateState,
                                                                      @ApiParam(value = "科室名称状态", required = true) @RequestParam(name = "deptState") Integer deptState){
        PageVO<Map<String,Object>> reportDddMonitorList = iClinicalMedicationService.getStrengthAntimicrobialUseList(page,startTime,endTime,deptName,dateState,deptState);
        return Result.ok(reportDddMonitorList);
    }

    @GetMapping("getRankingAntimicrobialUse")
    @ApiOperation(value = "抗菌药使用量排名(5)")
    public Result<PageVO<Map<String,Object>>> getRankingAntimicrobialUse(@ApiParam(value = "分页",required = true) PageVO<Map<String,Object>> page,
                                                                               @ApiParam(value = "开始时间") @RequestParam(name = "startTime",required = false) String startTime,
                                                                               @ApiParam(value = "结束时间") @RequestParam(name = "endTime",required = false) String endTime,
                                                                               @ApiParam(value = "科室名称") @RequestParam(name = "deptName",required = false) String deptName,
                                                                               @ApiParam(value = "抗菌药名称") @RequestParam(name = "drugName",required = false) String drugName,
                                                                               @ApiParam(value = "账期状态", required = true) @RequestParam(name = "dateState") Integer dateState,
                                                                               @ApiParam(value = "科室名称状态", required = true) @RequestParam(name = "deptState") Integer deptState,
                                                                               @ApiParam(value = "抗菌药名称状态", required = true) @RequestParam(name = "drugState") Integer drugState){
        PageVO<Map<String,Object>> reportDddMonitorList = iClinicalMedicationService.getRankingAntimicrobialUseList(page,startTime,endTime,deptName,drugName,dateState,deptState,drugState);
        return Result.ok(reportDddMonitorList);
    }

    @GetMapping("getOverLimitPrescription")
    @ApiOperation(value = "超限处方监控(6)")
    public Result<PageVO<Map<String,Object>>> getOverLimitPrescription(@ApiParam(value = "分页",required = true) PageVO<Map<String,Object>> page,
                                                                             @ApiParam(value = "开始时间") @RequestParam(name = "startTime",required = false) String startTime,
                                                                             @ApiParam(value = "结束时间") @RequestParam(name = "endTime",required = false) String endTime,
                                                                             @ApiParam(value = "科室名称") @RequestParam(name = "deptName",required = false) String deptName,
                                                                             @ApiParam(value = "医生名称") @RequestParam(name = "docName",required = false) String docName,
                                                                             @ApiParam(value = "门诊号") @RequestParam(name = "medRecordNo",required = false) String medRecordNo,
                                                                             @ApiParam(value = "门特处方") @RequestParam(name = "clinicSpecFlag",required = false) Integer clinicSpecFlag,
                                                                             @ApiParam(value = "处方金额") @RequestParam(name = "prescriptCost",required = false) String prescriptCost){
        PageVO<Map<String,Object>> data = iClinicalMedicationService.getOverLimitPrescriptionList(page,startTime,endTime,deptName,docName,medRecordNo,clinicSpecFlag,prescriptCost);
        return Result.ok(data);
    }

    @GetMapping("getOverPrescriptionDetail")
    @ApiOperation(value = "超限处方明细")
    public Result<Map<String,Object>> getOverPrescriptionDetail(@ApiParam(value = "处方流水号") @RequestParam(name = "prescriptNoColl",required = false) String prescriptNoColl){
        Map<String,Object> data = iClinicalMedicationService.getOverPrescriptionDetail(prescriptNoColl);
        return Result.ok(data);
    }

    @GetMapping("getReportDrugPctMonitor")
    @ApiOperation(value = "药占比监控(7)")
    public Result<PageVO<Map<String,Object>>> getReportDrugPctMonitor(@ApiParam(value = "分页",required = true) PageVO<Map<String,Object>> page,
                                                                  @ApiParam(value = "开始时间") @RequestParam(name = "startTime",required = false) String startTime,
                                                                  @ApiParam(value = "结束时间") @RequestParam(name = "endTime",required = false) String endTime,
                                                                  @ApiParam(value = "开单科室") @RequestParam(name = "deptName",required = false) String deptName,
                                                                  @ApiParam(value = "开单医生") @RequestParam(name = "docName",required = false) String docName,
                                                                  @ApiParam(value = "诊疗类型") @RequestParam(name = "diagTreatType",required = false) String diagTreatType,
                                                                  @ApiParam(value = "账期状态", required = true) @RequestParam(name = "dateState") Integer dateState,
                                                                  @ApiParam(value = "开单科室状态", required = true) @RequestParam(name = "deptState") Integer deptState,
                                                                  @ApiParam(value = "开单医生状态", required = true) @RequestParam(name = "docNameState") Integer docNameState,
                                                                      @ApiParam(value = "诊疗类型状态", required = true) @RequestParam(name = "diagTreatState") Integer diagTreatState) {
        PageVO<Map<String,Object>> reportDrugPctMonitor = iClinicalMedicationService.getReportDrugPctMonitorList(page,startTime,endTime,deptName,docName,diagTreatType,dateState,deptState,docNameState,diagTreatState);
        return Result.ok(reportDrugPctMonitor);
    }

    @GetMapping("getReportBasicDrugMonitor")
    @ApiOperation(value = "基本药物监控(8)")
    public Result<PageVO<Map<String,Object>>> getReportBasicDrugMonitor(@ApiParam(value = "分页",required = true) PageVO<Map<String,Object>> page,
                                                                      @ApiParam(value = "开始时间") @RequestParam(name = "startTime",required = false) String startTime,
                                                                      @ApiParam(value = "结束时间") @RequestParam(name = "endTime",required = false) String endTime,
                                                                      @ApiParam(value = "科室名称") @RequestParam(name = "deptName",required = false) String deptName,
                                                                      @ApiParam(value = "诊疗类型") @RequestParam(name = "diagTreatType",required = false) String diagTreatType,
                                                                      @ApiParam(value = "账期状态", required = true) @RequestParam(name = "dateState") Integer dateState,
                                                                      @ApiParam(value = "科室名称状态", required = true) @RequestParam(name = "deptState") Integer deptState,
                                                                      @ApiParam(value = "诊疗类型状态", required = true) @RequestParam(name = "diagTreatState") Integer diagTreatState) {
        PageVO<Map<String,Object>> reportBasicDrugMonitor = iClinicalMedicationService.getReportBasicDrugMonitorList(page,startTime,endTime,deptName,diagTreatType,dateState,deptState,diagTreatState);
        return Result.ok(reportBasicDrugMonitor);
    }
}
